package com.rc.saas.tenant.service.tenant;

import com.rc.saas.tenant.mapper.tenantOrder.TenantOrderMapper;
import com.rc.saas.tenant.model.tenant.TenantOpenService;
import com.rc.saas.tenant.model.tenant.TenantOpenServiceExample;
import com.rc.saas.tenant.model.tenantOrder.TenantOrder;
import com.rc.saas.tenant.model.tenantOrder.TenantOrderExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TenantOrderSerivceImpl implements TenantOrderSerivce {
    @Autowired
    private TenantOrderMapper tenantOrderMapper;
    @Override
    public TenantOrderMapper getMapper() {
        return tenantOrderMapper;
    }

    @Override
    public TenantOrder selectByTypeCode(String code, String tenantCode) {
        TenantOrderExample example = new TenantOrderExample();
        example.createCriteria().andTenantCodeEqualTo(tenantCode).andServiceTypeCodeEqualTo(code);
        List <TenantOrder> tenantOrders = tenantOrderMapper.selectByExample(example);
        if (tenantOrders!=null &&tenantOrders.size()>0){
            return tenantOrders.get(0);
        }
        return null;
    }
}
